<?php
namespace app\company\model;


use Exception;

class WarehouseArea extends Base
{


    /**
     * @param WarehouseArea $model
     * @return void
     * @throws Exception
     */
    public static function onBeforeDelete(WarehouseArea $model): void
    {
//        $model->force(true);//真实删除
        if($model->companyOrderStorages()->sum('quantity')>0) exception('删除失败，该仓库下存在商品');
        if($model->warehouseStorages()->count()>0) $model->warehouseStorages->delete();
    }


}